﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <string>
using namespace std;

template<class T1, class T2>
class PersonFriend
{
	//1.友元函数类内实现；
	friend void printPerson(PersonFriend<T1, T2>& p)
	{
		cout << "姓名：" << p.m_Name << " ，年龄：" << p.m_Age << endl;
	}
public:
	PersonFriend(T1 name, T2 age)
	{
		this->m_Name = name;
		this->m_Age = age;
	}
private:
	T1 m_Name;
	T2 m_Age;
};
void testClassTemplateFriend()
{
	PersonFriend<string, int>p("Tom", 10);
	printPerson(p);//姓名：Tom ，年龄：10
}

//main306：友元碰到类模板友元函数类内实现
int main306()
{
	testClassTemplateFriend();

	system("pause");
	return EXIT_SUCCESS;
}